
 FE.Transport.disableProxy();
 FE.Transport.allowDomain('http://s3.amazonaws.com/freeearth/crossdomain.xml');
 var map;
 var pmap;

 var _timer;
 var _weatherTimer;
 var _timeout;
 
var geocoder = null;
var spx, spy, epx,epy;

 function mainDemo() {
	//alert("mainDemo");
	showAirRoute();
	//  _timer = setInterval(rotate, 100);
	//  setTimeout('_weatherTimer = setInterval("showWeatherData()", 100);', 1400);
 }

 function onMapLoad() {
	//alert("onMapLoad");
	FE.Transport.allowDomain('http://s3.amazonaws.com/freeearth/crossdomain.xml');
	this.zoomTo(FE.Map.RADIUS*3);
	this.setTargetLatLng(new FE.LatLng(30,0));
 }

 function onLoad() {
	//alert("onLoad");
	map = new FE.Map(document.getElementById('map'));
	map.onLoad = onMapLoad;
	map.load();
	initialize();
	/*  pmap = new PMap(document.getElementById('map2d'));
	PEvent.addListener(pmap, 'move', on2DMove);
	document.getElementById('map2d').style.display = 'none';*/
	Event.observe('map', 'mousedown', stopRotate);
 }

 function reset() {
	//alert("reset");
	clearInterval(_timer);
	clearInterval(_weatherTimer);
	clearTimeout(_timeout);
	clearLayers();
	map.getCamera().setTilt(0);
	map.closeInfoWindow();
	map.clearOverlays();
	map.zoomTo(FE.Map.RADIUS * 3);
	map.resize(477, 457);
	document.getElementById('map2d').style.display = 'none';
 }
function clearLayers() {
	//alert("clearLayers");
	var lm = map.getLayerManager();
	var layers = lm.getLayers();
	for(var i=0; i<layers.length; i++)
		if (layers[i].name == 'etna')
			lm.removeLayer(layers[i]);
	etnaLayer = null;
}
var etnaLayer = null;
var planeIcon = null;

function showAirRoute() {
	//alert("showAirRoute");
	reset();
	var start = new FE.LatLng(spy ,spx);
	var end = new FE.LatLng(epy, epx);
	if(spx < epx){
		planeIcon = new FE.Icon('http://cfs6.tistory.com/image/20/tistory/2008/05/05/21/00/481ef6e334d20', 1, 1);
	}
	else{
		planeIcon = new FE.Icon('http://cfs6.tistory.com/image/18/tistory/2008/05/05/21/00/481ef6ed33fbc', 1, 1);
	}
	var airline = new FE.Polyline([start, end]);
	var opts = new FE.LabelOpts();
	opts.fontName = 'Verdana';
	opts.setColor('yellow');
	opts.fontSize = 16;
	var startArr =document.getElementById("startPoint").value.split(",");
	var startTxt = startArr[0];
	var endArr = document.getElementById("endPoint").value.split(",");
	var endTxt = endArr[0];	
	var mia = new FE.Label(start, startTxt, opts);
	var cdg = new FE.Label(end, endTxt, opts);
	var plane = new FE.Pushpin(start, planeIcon);
	map.addOverlay(plane);
	map.addOverlay(mia);
	map.addOverlay(cdg);
	map.addOverlay(airline);
	map.setTargetLatLng(start);
	map.panTo(end, 5, "linear");
	plane.followPolyline(airline, 10);
}

    function initialize() {
      geocoder = new GClientGeocoder();
	map.resize(477, 457);
    }
    function showAddress(start_point, end_point) {
      var startArr = start_point.split(",");
      var endArr = end_point.split(",");
      var startPoint = startArr[1]+" "+startArr[2];
      var endPoint = endArr[1]+" "+endArr[2];
      if (geocoder) {
        geocoder.getLatLng(
          startPoint,
          function(point) {
            if (!point) {
              alert(startPoint + " not found");
            } else {
				spy = point.lat();
				spx = point.lng();	
            }
          }
        );
        geocoder.getLatLng(
          endPoint,
          function(point) {
            if (!point) {
              alert(endPoint + " not found");
            } else {
				epy=point.lat();
                epx=point.lng();
            }
          }
        );
      }
      setTimeout(mainDemo,500);
    }

//  ]]>


/* FE.Transport.disableProxy();
 FE.Transport.allowDomain('http://s3.amazonaws.com/freeearth/crossdomain.xml');
 var map;
 var pmap;

 var _timer;
 var _weatherTimer;
 var _timeout;

 
var geocoder = null;
var spx, spy, epx,epy;

 function mainDemo() {
	//alert("mainDemo");
	showAirRoute();
	//  _timer = setInterval(rotate, 100);
	//  setTimeout('_weatherTimer = setInterval("showWeatherData()", 100);', 1400);
 }

 function onMapLoad() {
	//alert("onMapLoad");
	FE.Transport.allowDomain('http://s3.amazonaws.com/freeearth/crossdomain.xml');
	this.zoomTo(FE.Map.RADIUS*3);
	this.setTargetLatLng(new FE.LatLng(30,0));
 }

 function onLoad(city) {
	//alert("onLoad");
	map = new FE.Map(document.getElementById('map'));
	map.onLoad = onMapLoad;
	map.load();
	initialize();
	/*  pmap = new PMap(document.getElementById('map2d'));
	Event.addListener(pmap, 'move', on2DMove);
	document.getElementById('map2d').style.display = 'none';
	Event.observe('map', 'mousedown', stopRotate);
 }

 function reset() {
	//alert("reset");
	clearInterval(_timer);
	clearInterval(_weatherTimer);
	clearTimeout(_timeout);
	clearLayers();
	map.getCamera().setTilt(0);
	map.closeInfoWindow();
	map.clearOverlays();
	map.zoomTo(FE.Map.RADIUS * 3);
	map.resize(477, 457);
	document.getElementById('map2d').style.display = 'none';
 }
function clearLayers() {
	//alert("clearLayers");
	var lm = map.getLayerManager();
	var layers = lm.getLayers();
	for(var i=0; i<layers.length; i++)
		if (layers[i].name == 'etna')
			lm.removeLayer(layers[i]);
	etnaLayer = null;
}
var etnaLayer = null;
var planeIcon = new FE.Icon('http://freeearth.poly9.com/images/ico_plane.gif', 1, 1);

function showAirRoute() {
	//alert("showAirRoute");
	reset();
	var start = new FE.LatLng(spy ,spx);
	var end = new FE.LatLng(epy, epx);
	var airline = new FE.Polyline([start, end]);
	var opts = new FE.LabelOpts();
	opts.fontName = 'Verdana';
	opts.setColor('yellow');
	opts.fontSize = 16;
	var startTxt = document.getElementById("startPoint").value;
	var endTxt = document.getElementById("endPoint").value;	
	var mia = new FE.Label(start, startTxt, opts);
	var cdg = new FE.Label(end, endTxt, opts);
	var plane = new FE.Pushpin(start, planeIcon);
	map.addOverlay(plane);
	map.addOverlay(mia);
	map.addOverlay(cdg);
	map.addOverlay(airline);
	map.setTargetLatLng(start);
	map.panTo(end, 5, "linear");
	plane.followPolyline(airline, 10);
}

    function initialize() {
      geocoder = new GClientGeocoder();
	map.resize(477, 457);
    }
    function showAddress(startPiont, endPoint) {
      if (geocoder) {
        geocoder.getLatLng(
          startPiont,
          function(point) {
            if (!point) {
              alert(startPiont + " not found");
            } else {
		spy = point.lat();
		spx = point.lng();	
            }
          }
        );
        geocoder.getLatLng(
          endPoint,
          function(point) {
            if (!point) {
              alert(endPoint + " not found");
            } else {
		epy=point.lat();
                epx=point.lng();
            }
          }
        );
      }
      	setTimeout(mainDemo,5000);
    }
 */